<template>
  <div>{{detail}}</div>
</template>

<script>
export default {
  data () {
    return {
      detail: {}
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {
      vm.$ajax.getProductDetail(to.params.id)
        .then(resp => {
          if (resp.data.code === 200) {
            vm.detail = resp.data.data
            vm.$bus.$emit('changeTitle', resp.data.data.shop.title)
          }
        })
      vm.$bus.$emit('toggleBackDisplay', true)
    })
  },
  beforeRouteLeave (to, from, next) {
    this.$bus.$emit('toggleBackDisplay')
    next()
  }
}
</script>

<style>

</style>
